define(['hr.common'
, 'app/hrManagerRbac/dictionary/dictionary.model'
, 'app/mdSheQuHospitalBase/factory/factory.model'
], function(common
, Dictionary
, Factory
){
    function InitModel(){
        var p = {
            url: '/medicine/findAllByPage',
            param: '',
            //场景一：columns和operation中width字段值使用百分比，其总和为100%；
            //场景二：columns和operation中width字段值用固定像素值，比如'50px'
            columns: [
                [
                    {id: 'barCode', width: '10%', text: '条形码'},
                    {id: 'medicineName', width: '10%', text: '药品名称'},
                    {id: 'medicineNamePy', width: '7%', text: '药品名称拼音'},
                    {id: 'factory.factoryName', width: '7%', text: '厂家'},
                    //{id: 'qrCode', width: '4%', text: '二维码'},
                    {id: 'serialNumber', width: '7%', text: '货号'},
                    {id: 'type.content', width: '7%', text: '药品类型'},
                    {id: 'directives', width: '4%', text: '批文'},
                    {id: 'batch', width: '4%', text: '批号'},
                    {id: 'specifications', width: '7%', text: '规格'},
                    {id: 'bid', width: '7%', text: '进价'},
                    {id: 'retailPrice', width: '7%', text: '零售价'},
                    {id: 'vipPrice', width: '4%', text: '会员价'}

                ]
            ],
            operation: [
                {width: '5%',icon: 'icon-search',text: '详细', clickOperations: 'showData'},
                {width: '5%',icon: 'icon-pencil',text: '修改', clickOperations: 'updateData'},
                {width: '5%',icon: 'icon-cancel-2',text: '删除', clickOperations: 'deleteData'}
            ],
            pageItem: {'id': '10', 'text': '10'},
            title: '药品表列表'
        };
        var tableModel = common.createTableModel(p);
        var model  = {
            searchModel: {
                barCode: ko.observable(''),
                //qrCode: ko.observable(''),
                serialNumber: ko.observable(''),
                type: ko.observable(new Dictionary().dialogModel.dictionaryModel),
                directives: ko.observable(''),
                batch: ko.observable(''),
                specifications: ko.observable(''),
                bid: ko.observable(''),
                retailPrice: ko.observable(''),
                vipPrice: ko.observable(''),
                medicineName: ko.observable(''),
                medicineNamePy: ko.observable(''),
                factory: ko.observable(new Factory().dialogModel.factoryModel)
            },
            tableModel: tableModel,
            dialogModel: {
                medicineModel: {
                    id: ko.observable(''),
                    barCode: ko.observable(''),
                    //qrCode: ko.observable(''),
                    serialNumber: ko.observable(''),
                    type: ko.observable(new Dictionary().dialogModel.dictionaryModel),
                    directives: ko.observable(''),
                    batch: ko.observable(''),
                    specifications: ko.observable(''),
                    bid: ko.observable(''),
                    retailPrice: ko.observable(''),
                    vipPrice: ko.observable(''),
                    medicineName: ko.observable(''),
                    medicineNamePy: ko.observable(''),
                    factory: ko.observable(new Factory().dialogModel.factoryModel)
                    /*
                    通过extend方法，添加对该字段的验证规则，下面示例表示，content字段必填且最大长度为20
                    content: ko.observable().extend({
                        required: {
                            message:'字典名称不允许为空'
                        },
                        maxLength: {
                            params: 20,
                            message:'字典说明长度不允许超过{0}'
                        }
                    })
                    */
                }
                , dictionaryArray: ko.observableArray()
                , factoryArray: ko.observableArray()
            }
        };
        return model;
    }
    return InitModel;
});